<style>
    .modal_handover{ }
    .modal_handoverbox{padding:15px;}
    .modal_handover_top{ border:1px solid #CCC; padding:10px;}
    .blue{color:#10F}
    .modal_handover tr td:last-child{ text-align:right; color:#10F}
    .modal_handoverboxfoot{padding:15px 0 0 0; height:50px;}
</style>
<div class="modal_handover" style="display:none">
    <div class="modal_handoverbox">
        <form id="modal_handoverform"  class="layui-form"  onsubmit="return false;">
            <div class="modal_handover_top"> 收银员：<span class="blue" id="mhandover_username">{$user['realname']}</span> <span class="pull-right blue" id="mhandover_time">-</span> </div>
            <div class="layui-form">
                <table class="layui-table" lay-skin="line">
                    <tbody>
                    <tr>
                        <td><b>总收入</b></td>
                        <td id="mhandover_1">0</td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="layui-form">
                        <table class="layui-table" lay-skin="line">
                            <tbody>
                            <tr>
                                <td>总金额</td>
                                <td id="mhandoversale_1">0</td>
                            </tr>
                            <tr>
                                <td>优惠金额</td>
                                <td id="mhandoversale_2">0</td>
                            </tr>
                            <tr>
                                <td><b>实付金额</b></td>
                                <td id="mhandoversale_3">0</td>
                            </tr>
                            <tr>
                                <td>交易笔数</td>
                                <td id="mhandoversale_4">0</td>
                            </tr>
                            <tr>
                                <td>商品数量</td>
                                <td id="mhandoversale_5">0</td>
                            </tr>

                            <tr>
                                <td>微信</td>
                                <td class="mhandoverpay" id="mhandoverpay_0">0</td>
                            </tr>
                            <tr>
                                <td>支付宝</td>
                                <td  class="mhandoverpay" id="mhandoverpay_1">0</td>
                            </tr>
                            <tr>
                                <td>现金</td>
                                <td  class="mhandoverpay" id="mhandoverpay_2">0</td>
                            </tr>
                            <tr>
                                <td>银行卡</td>
                                <td  class="mhandoverpay" id="mhandoverpay_3">0</td>
                            </tr>
                            <tr>
                                <td>会员卡</td>
                                <td  class="mhandoverpay" id="mhandoverpay_4">0</td>
                            </tr>
                            {if $shop["custom_pay1_status"]}
                            <tr>
                                <td>{$shop["custom_pay1"]}</td>
                                <td  class="mhandoverpay" id="mhandoverpay_5">0</td>
                            </tr>
                            {/if}
                            {if $shop["custom_pay2_status"]}
                            <tr>
                                <td>{$shop["custom_pay2"]}</td>
                                <td  class="mhandoverpay" id="mhandoverpay_6">0</td>
                            </tr>
                            {/if}
                            {if $shop["custom_pay3_status"]}
                            <tr>
                                <td>{$shop["custom_pay3"]}</td>
                                <td  class="mhandoverpay" id="mhandoverpay_7">0</td>
                            </tr>
                            {/if}
                            {if $shop["custom_pay4_status"]}
                            <tr>
                                <td>{$shop["custom_pay4"]}</td>
                                <td  class="mhandoverpay" id="mhandoverpay_8">0</td>
                            </tr>
                            {/if}
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="layui-form">
                        <table class="layui-table" lay-skin="line">
                            <tbody>
                            <tr>
                                <td><b>充值收入</b></td>
                                <td id="mhandovercharge">0</td>
                            </tr>
                            <tr>
                                <td>微信</td>
                                <td id="mhandoverchargepay_0">0</td>
                            </tr>
                            <tr>
                                <td>支付宝</td>
                                <td id="mhandoverchargepay_1">0</td>
                            </tr>
                            <tr>
                                <td>现金</td>
                                <td id="mhandoverchargepay_2">0</td>
                            </tr>
                            <tr>
                                <td>银行卡</td>
                                <td id="mhandoverchargepay_3">0</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-form">
                        <table class="layui-table" lay-skin="line">
                            <tbody>
                            <tr>
                                <td><b>挂单</b></td>
                                <td id="mhandoverholdorder">0</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-form">
                        <table class="layui-table" lay-skin="line">
                            <tbody>
                            <tr>
                                <td><b>应有现金</b></td>
                                <td id="mhandoverallcash">0</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-form">
                        <table class="layui-table" lay-skin="line">
                            <tbody>
                            <tr>
                                <td><b>新增会员</b></td>
                                <td id="mhandovernewmember">0</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="modal_handoverboxfoot">
                <input type="checkbox" name="isprint" value="1" title="打印" checked/>
        <span class="pull-right">
        	<button type="button" class="layui-btn layui-btn-normal modal_handoversubmit">交班并退出</button>
            <button type="button" class="layui-btn layui-btn-primary modal_handoverboxclose">关闭</button>
        </span>
            </div>
        </form>
    </div>

</div>
<script>
    function funSys_handover(){
        layer.open({
            type: 1,
            title:"交班",
            area:"700px",
            skin: 'layui-layer-rim',
            content:$(".modal_handover").show(),
            success: function(layero, index){
                $(".modal_handoverboxclose").on("click",function(){
                    layer.close(index);
                });
                $(".modal_handoversubmit").on("click",function(){
                    var timer=100;
                    if($(".modal_handoverboxfoot .layui-form-checked").size()){
                        fun_print(6,0);
                        timer=3000;
                    }
                    setTimeout(function(){
                        location.href="{php echo $this->createMobileUrl('index',array('op'=>'logout'))}";
                    },timer);
                });
                var index2=layer.load(1, {shade: [0.1,'#fff']});
                $.post("{php echo $this->createMobileUrl('index',array('op'=>'handover'))}",{},function(returnstr){
                    layer.close(index2);
                    console.log(returnstr);
                    var result=eval("("+returnstr+")");
                    if(result.success){
                        $("#mhandover_time").text(result.time);
                        $("#mhandoverholdorder").text(result.holdorder);
                        var items=result.item;
                        $("#mhandoversale_1").text("￥ "+fee2num(items.fee1));
                        $("#mhandoversale_2").text("￥ "+fee2num(items.fee2));
                        $("#mhandoversale_3").text("￥ "+fee2num(items.fee3));
                        $("#mhandoversale_4").text(items.num1);
                        $("#mhandoversale_5").text(items.num2);
                        var paylist=result.paytypelist;
                        $(".mhandoverpay").each(function(){
                            var index=parseInt($(this).attr("id").replace("mhandoverpay_",""));
                            $(this).text("￥ "+(paylist[index]!=null ? fee2num(paylist[index].fee1): "-"));
                        });
                        var chargeitem=result.chargeitems;
                        $("#mhandovercharge").text("("+chargeitem.num1+") ￥ "+fee2num(chargeitem.fee1));
                        var chargelist=result.chargelist;
                        $("#mhandoverchargepay_0").text("￥ "+(chargelist[0]!=null ? fee2num(parseInt(chargelist[0])) : "-"));
                        $("#mhandoverchargepay_1").text("￥ "+(chargelist[1]!=null ? fee2num(parseInt(chargelist[1])) : "-"));
                        $("#mhandoverchargepay_2").text("￥ "+(chargelist[2]!=null ? fee2num(parseInt(chargelist[2])) : "-"));
                        $("#mhandoverchargepay_3").text("￥ "+(chargelist[3]!=null ? fee2num(parseInt(chargelist[3])) : "-"));
                        var allcash=(chargelist[2]!=null ? parseInt(chargelist[2]) : 0) + (paylist[2]!=null ? parseInt(paylist[2].fee1) : 0);
                        $("#mhandoverallcash").text("￥" + fee2num(allcash));
                        $("#mhandovernewmember").text(result.member!=null ? result.member : "-");
                        var allfee=(items.fee3!=null ? parseInt(items.fee3) : 0)+(chargeitem.fee1!=null ? parseInt(chargeitem.fee1):0);
                        $("#mhandover_1").html("<b>￥ "+fee2num(allfee)+"</b>");
                    }else{
                        layer.msg(result.msg,{icon:2,time:1500});
                        return;
                    }
                });
            },
            end:function(){
                $(".modal_handover").hide();
                $(".modal_handoversubmit").unbind("click");
                $(".modal_handoverboxclose").unbind("click");
            }
        });
    }

</script>